package com.jwdf.uda.http.action;

import android.content.Context;

import com.jwdf.uda.bean.PbBean;
import com.jwdf.uda.http.AHttpService;
import com.jwdf.uda.http.ApiService;

import retrofit2.Call;

/**
 * Created by Administrator on 2016/9/13.
 */
public class QuizReplyListAction extends AHttpService<PbBean.PbResQuestionAnswerList> {
    private int quizId;
    private int offset;
    private PbBean.PbSignBaseAnswerSort sort;


    private QuizReplyListAction(Context context, int id, int offset) {
        super(context);
        this.quizId = id;
        this.offset = offset;
    }

    private QuizReplyListAction(Context context, int id, int offset, PbBean.PbSignBaseAnswerSort sort) {
        super(context);
        this.quizId = id;
        this.offset = offset;
        this.sort = sort;
    }

    public static QuizReplyListAction newInstance(Context context, int id, int offset) {
        return new QuizReplyListAction(context, id, offset);
    }

    public static QuizReplyListAction newInstance(Context context, int id, int offset, PbBean.PbSignBaseAnswerSort sort) {
        return new QuizReplyListAction(context, id, offset, sort);
    }

    @Override
    protected Call newRetrofitCall(ApiService apiService, PbBean.PbBaseClientInfo.Builder baseBuilder) {
        PbBean.PbReqQuestionAnswerList.Builder builder = PbBean.PbReqQuestionAnswerList.newBuilder();
        builder.setBaseClientInfo(baseBuilder);
        builder.setQuestionId(quizId);
        builder.setOffset(offset);
        builder.setSort(sort != null ? sort : PbBean.PbSignBaseAnswerSort.ANSWER_SORT_BY_LIKE_DESC);
        return apiService.quizGetReplys(builder.build());
    }
}
